package com.shuqi.common;

import android.content.Context;
import android.os.Environment;
import android.util.Log;

import com.shuqi.common.utils.SqImageManager;
import com.shuqi.common.utils.Util;
import com.shuqi.service.ConnectionChangeReceiver;

/**
 * 配置信息
 * 
 * @author Jianda.Yang
 * @date 2013-12-20 下午2:08:17
 * @version 1.0
 */
public class Config {
    /***********************************************/
    /* Not packaging personnel prohibited to modify related information */
    /** 软件版本信息 */
    public static final String VERSION_INFO = "140721";
    public static final String SOFT_ID = "1";
    public static final String MIN_SDK_VERSION = "3";
    public static final String PACKAGENAME_VERIFY = "com.shuqi.controller";//校验软件签名信息，只有打谷歌市场特殊包需要修改
    /***********************************************/

    /** 书旗客户端根路径(不含'/'字符) */
    public static final String ROOT_PATH = Environment.getExternalStorageDirectory() + "/shuqi";


    /** 除了(封面，主页顶部，启动图)之外的其他图片缓冲区 */
    @Deprecated
    public final static String DEFAULT_PATH_COVER = ROOT_PATH + "/cover/";// 7.X残留文件夹，8.X不再使用

    /** 封面图片缓冲区 */
    @Deprecated
    public final static String DEFAULT_PATH_BOOKCOVER = ROOT_PATH + "/bookindexcover/";// 7.X残留文件夹，8.X不再使用

    /** 启动图缓存 */
    public final static String DEFAULT_PATH_LOADINGPIC = ROOT_PATH + "/loadingpic/";

    /** load自主图缓存 */
    public final static String DEFAULT_PATH_LOADINADGPIC = ROOT_PATH + "/loadad/";

    /** 更新软件下载路径 */
    public final static String DEFAULT_PATH_APPDOWNLOAD = ROOT_PATH + "/download/";

    /** 书旗客户端书包路径 */
    public static final String BOOKBAG_PATH = ROOT_PATH + "/bookbag/";

    /** 书旗客户端从一搜网页下载的书籍路径(不含'/'字符) */
    public static final String BOOK_YISOU_PATH = ROOT_PATH + "/downfromyisou";

    /** 书旗书籍章节内容路径 */
    public final static String DEFAULT_SHUQI_CHAPTER_DOWN_CACHE_PATH = ROOT_PATH
            + "/shuqi/downloadcache/";
    /** 书旗书籍章节内容路径 */
    public final static String DEFAULT_SHUQI_CHAPTER_CACHE_PATH = ROOT_PATH
            + "/shuqi/chaptercache/";
    /** 一搜书籍章节内容路径 */
    public final static String DEFAULT_YISOU_CHAPTER_CACHE_PATH = ROOT_PATH
            + "/yisou/chaptercache/";
    
    /** 封面图片存放路径（小图） */
    public static final String BOOK_COVER_SMALL_CACHE_PATH = ROOT_PATH + "/cache/" + SqImageManager.IMG_COVER + "/";
    /** 封面图片存放路径（大图） */
    public static final String BOOK_COVER_BIG_CACHE_PATH = ROOT_PATH + "/cache/" + SqImageManager.IMG_BIG_PICTURE + "/";
    
    /** 当前的网络类型 */
    private static String netType;
    public static String STANDBY_SERVER;// 服务器地址
    public static String STANDBY_SERVER1;// 服务器地址1
    public static String STANDBY_SERVER2;// 服务器地址2
    public static String STANDBY_SERVER3;// 服务器地址2

    // 账户相关 加密串
    public static final String ACCOUNTENCRYPTKEY = "shuqishuqimaster";

    /** 退出软件时重置静态变量 */
    public static void onExit() {
        netType = null;
        Log.e("Config", "退出软件时重置静态变量");
    }

    /** 获取当前的网络类型 */
    public static String getNetType(Context context) {
        if (Util.isNetworkConnected(context)) {
            if (netType == null) {
                ConnectionChangeReceiver.getNetType(context);
            }
        }

        return netType;
    }

    /**
     * 当网络类型发生变化时，更新当前网络类型
     * 
     * @param netType
     */
    public static void setNetType(String netType) {
        Config.netType = netType;
    }

    public static final int PARSE_XML_RETRY_TIMES = 3;
    /**
     * 是否显示公告
     */
    public static Boolean isShowNotice = true;
}
